X-Git-Url: http://git.cyclocoop.org/%27%20.%20%24prefix%20.%20Wiki::transformTitleToURI%28%24matches%5B1%5D%29%20.%20%27?a=blobdiff_plain;f=tests%2FtestHelpers.inc;h=13694063c165f992f4f3f9b163bbbe432c3ee6de;hb=386bed1ffd9da7eb5830e0c2386e5dc79e261dfe;hp=d04e0fcb54fb6969cfae58fa6af22e64ab43e601;hpb=09ff912ddd3c8b153cdd49082bfc8eabb3b522e5;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index d04e0fcb54..13694063c1 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -837,30 +837,60 @@ class DjVuSupport { * Initialize and detect the tidy support */ class TidySupport { - private $internalTidy; - private $externalTidy; + private $enabled; + private $config; /** * Determine if there is a usable tidy. */ - public function __construct() { - global $wgTidyBin; - - $this->internalTidy = extension_loaded( 'tidy' ) && - class_exists( 'tidy' ) && !wfIsHHVM(); - - $this->externalTidy = is_executable( $wgTidyBin ) || - Installer::locateExecutableInDefaultPaths( [ $wgTidyBin ] ) - !== false; - } - - /** - * Returns true if we should use internal tidy. - * - * @return bool - */ - public function isInternal() { - return $this->internalTidy; + public function __construct( $useConfiguration = false ) { + global $IP, $wgUseTidy, $wgTidyBin, $wgTidyInternal, $wgTidyConfig, + $wgTidyConf, $wgTidyOpts; + + $this->enabled = true; + if ( $useConfiguration ) { + if ( $wgTidyConfig !== null ) { + $this->config = $wgTidyConfig; + } elseif ( $wgUseTidy ) { + $this->config = [ + 'tidyConfigFile' => $wgTidyConf, + 'debugComment' => false, + 'tidyBin' => $wgTidyBin, + 'tidyCommandLine' => $wgTidyOpts + ]; + if ( $wgTidyInternal ) { + $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP'; + } else { + $this->config['driver'] = 'RaggettExternal'; + } + } else { + $this->enabled = false; + } + } else { + $this->config = [ + 'tidyConfigFile' => "$IP/includes/tidy/tidy.conf", + 'tidyCommandLine' => '', + ]; + if ( extension_loaded( 'tidy' ) && class_exists( 'tidy' ) ) { + $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP'; + } else { + if ( is_executable( $wgTidyBin ) ) { + $this->config['driver'] = 'RaggettExternal'; + $this->config['tidyBin'] = $wgTidyBin; + } else { + $path = Installer::locateExecutableInDefaultPaths( $wgTidyBin ); + if ( $path !== false ) { + $this->config['driver'] = 'RaggettExternal'; + $this->config['tidyBin'] = $wgTidyBin; + } else { + $this->enabled = false; + } + } + } + } + if ( !$this->enabled ) { + $this->config = [ 'driver' => 'disabled' ]; + } } /** @@ -869,6 +899,10 @@ class TidySupport { * @return bool */ public function isEnabled() { - return $this->internalTidy || $this->externalTidy; + return $this->enabled; + } + + public function getConfig() { + return $this->config; } }